package fun.eliauk.shuatiba.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import fun.eliauk.shuatiba.model.dto.question.QuestionQueryRequest;
import fun.eliauk.shuatiba.model.entity.Question;
import fun.eliauk.shuatiba.model.entity.User;
import fun.eliauk.shuatiba.model.vo.question.QuestionVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 题库服务
 */
public interface QuestionService extends IService<Question> {

    /**
     * 校验数据
     *
     * @param question
     * @param add      对创建的数据进行校验
     */
    void validQuestion(Question question, boolean add);

    /**
     * 获取查询条件
     *
     * @param questionQueryRequest
     * @return
     */
    QueryWrapper<Question> getQueryWrapper(QuestionQueryRequest questionQueryRequest);

    /**
     * 获取题库封装
     *
     * @param question
     * @param request
     * @return
     */
    QuestionVO getQuestionVO(Question question, HttpServletRequest request);

    /**
     * 分页获取题库封装
     *
     * @param questionPage
     * @param request
     * @return
     */
    Page<QuestionVO> getQuestionVOPage(Page<Question> questionPage, HttpServletRequest request);


    Page<Question> listQuestionByPage(QuestionQueryRequest questionQueryRequest);


    Page<Question> searchFromEs(QuestionQueryRequest questionQueryRequest);

    /**
     * 批量删除题目
     *
     * @param questionIdList 要删除的题目id
     */
    void batchDeleteQuestions(List<Long> questionIdList);

    /**
     * 批量向题库中插入数据
     *
     * @param questionsIds 题目ids
     * @param bankId       题库id
     * @param loginUser    当前登录用户
     */
    void batchAddQuestionsToBank(List<Long> questionsIds, Long bankId, User loginUser);

}
